package model

import (
	"gorm.io/gorm"
	"time"
)

type Post struct {
	gorm.Model   `json:"gorm.Model"`
	PostId       string `json:"post_id" gorm:"post_id;type:CHAR(38) NOT NULL;comment:post唯一id"` // uuid生成
	Title        string `json:"title" gorm:"column:title; type:VARCHAR(255) NOT NULL;comment:标题"`
	Desc         string `json:"desc" gorm:"column:desc;type:VARCHAR(1024) NOT NULL; comment:描述"`
	Content      string `json:"content" gorm:"column:content;type:TEXT NOT NULL; comment:内容"`
	Author       string `json:"author" gorm:"column:author;type:VARCHAR(38)  NOT NULL;comment:作者"`
	CategoryId   string `json:"categoryId" gorm:"column:category_id;type:CHAR(38) NOT NULL; comment:类别唯一id"`
	CategoryName string `json:"categoryName" gorm:"column:category_name; type:VARCHAR(38)  NOT NULL;comment:分类名"`
	Love         int    `json:"love" gorm:"column:love; comment:点赞次数"`
	Watch        int    `json:"watch" gorm:"column:watch; comment:浏览次数"`
}

type PostWithoutContent struct {
	PostId       string
	Title        string
	Desc         string
	Author       string
	Tags         []TagInfo
	CategoryId   string `gorm:"column:category_id"`
	CategoryName string `gorm:"column:category_name"`
	Love         int
	Watch        int
	CreatedAt    time.Time `gorm:"column:created_at"`
	CreateTime   string    `json:"create_time"`
}

func (Post) TableName() string {
	return "posts"
}

type RequestPost struct {
	Title        string    `json:"title"`
	Desc         string    `json:"desc"`
	Content      string    `json:"content"`
	Author       string    `json:"author"`
	CategoryId   string    `json:"category_id"`
	CategoryName string    `json:"category_name"`
	Tags         []TagInfo `json:"tags"`
}
type RequestUpdatePost struct {
	PostId       string    `json:"post_id"`
	Title        string    `json:"title"`
	Desc         string    `json:"desc"`
	Content      string    `json:"content"`
	Author       string    `json:"author"`
	CategoryId   string    `json:"category_id"`
	CategoryName string    `json:"category_name"`
	Tags         []TagInfo `json:"tags"`
}
type PostInfo struct {
	Content string
	Like    string
	Watch   string
}
